import { ref } from 'vue';

// 定义审批状态常量
const APPROVAL_STATUS = {
    UNEDITED: '0',
    APPROVED: '2',
    REJECTED: '3'
};

const useApproval = () => {
    const { proxy } = getCurrentInstance() as ComponentInternalInstance;

    const approvalVisible = ref(false);
    const approvalObj = ref<any>();

    /**
     * @description: 打开审批弹窗
     */
    const handleOpenApproval = (row: any) => {
        const { approvalStatus } = row;
        switch (approvalStatus) {
            case APPROVAL_STATUS.UNEDITED:
                return proxy?.$modal.msgError('福利采购订单未编辑，请编辑后再审核!');
            case APPROVAL_STATUS.APPROVED:
                return proxy?.$modal.msgError('福利采购订单审核已经通过，请勿重复点击!');
            case APPROVAL_STATUS.REJECTED:
                return proxy?.$modal.msgError('福利采购订单审核已被拒绝，请重新编辑后，再次审核!');
        }

        approvalObj.value = row;
        approvalVisible.value = true;
    };



    return {
        approvalVisible,
        approvalObj,
        handleOpenApproval
    }
};

export default useApproval;